<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<head>
  <title>Cluster管理</title>
</head>

<div class="row">
  <div class="col-xs-12">
    <table id="cluster_list_table" class="table table-bordered table-hover">
      <thead>
        <tr>
          <th>#Cluster Name</th>
          <th>#Broker Detail</th>
        </tr>
      </thead>
      <tbody>
        <c:forEach var="item" items="${clusterInfo}">
          <%--循环遍历map--%>
          <c:forEach var="cluster" items="${item}">
            <tr>
              <td>${cluster.key}</td>
              <td>
                <table class="table table-bordered table-hover">
                  <thead>
                  <tr>
                    <th>#Broker Name</th>
                    <th>#Broker Instance</th>
                  </tr>
                  </thead>
                  <tbody>
                    <%--${cluster.value}是个List<Map>的形式--%>
                    <c:forEach var="map" items="${cluster.value}">
                      <c:forEach var="broker" items="${map}">
                        <tr>
                          <td>${broker.key}</td>
                          <td>
                            <table class="table table-bordered table-hover">
                              <thead>
                              <tr>
                                <th>#BID</th>
                                <th>#Addr</th>
                                <th>#Version</th>
                                <th>#InTPS</th>
                                <th>#OutTPS</th>
                                <th>#InTotalYest</th>
                                <th>#OutTotalYest</th>
                                <th>#InTotalToday</th>
                                <th>#OutTotalToday</th>
                              </tr>
                              </thead>
                              <tbody>
                                <c:forEach var="instance" items="${broker.value}">
                                  <tr>
                                    <td>${instance.BID}</td>
                                    <td>${instance.Addr}</td>
                                    <td>${instance.Version}</td>
                                    <td>${instance.InTPS}</td>
                                    <td>${instance.OutTPS}</td>
                                    <td>${instance.InTotalYest}</td>
                                    <td>${instance.OutTotalYest}</td>
                                    <td>${instance.InTotalToday}</td>
                                    <td>${instance.OutTotalToday}</td>
                                  </tr>
                                </c:forEach>
                              </tbody>
                            </table>
                        </tr>
                      </c:forEach>
                    </c:forEach>
                  </tbody>
                </table>
            </tr>
          </c:forEach>
        </c:forEach>
      </tbody>
    </table>
  </div>
</div>
<script type="text/javascript">
  var scripts = [null, null];
  var _grid_id = "#cluster_list_table";	//表格 选择器
  ace.load_ajax_scripts(scripts, function() {
    //调整以适应页面大小  其中 $(".page-content") 为jqgrid的父级容器
    $(window).off('resize.jqGrid').on('resize.jqGrid', function () {
      setTimeout(function(){
        $(_grid_id).jqGrid("setGridWidth",$(".page-content").width());
        $(".ui-jqgrid-bdiv").width($(".page-content").width()+1);
      },50);
    });
  });
</script>